package a66weding.com.jiehuntong.pager;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.beans.DiyaddBean;

/**
 * Created by admin on 2016/6/14.
 */
public class Diy_DelliuchengPager extends BasePager implements AdapterView.OnItemClickListener {

    public Diy_DelliuchengPager(Activity activity) {
        super(activity);
    }

    @Override
    protected View getView() {
        View myDiyView = View.inflate(mActivity, R.layout.activity_diy_listview_add, null);
        ListView lv = (ListView) myDiyView.findViewById(R.id.lv);
        String[] strName = {"订婚", "登记", "对戒", "酒店", "婚纱照", "婚庆", "礼服", "邀请", "婚品", "化妆司仪", "摄影录像", "婚车", "邀请", "摄影录像", "婚车", "典礼", "回娘家", "蜜月"};
        List<DiyaddBean> list = new ArrayList<DiyaddBean>();
        for (int i = 0; i < strName.length; i++) {
            DiyaddBean object = new DiyaddBean();
            object.Name = strName[i];
            list.add(object);
        }
        MyDiyaddAdapter adapter = new MyDiyaddAdapter(mActivity, list);
        lv.setAdapter(adapter);

        lv.setOnItemClickListener(this);
        return myDiyView;
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        boolean flag = true;
        if (flag) {

        }
    }

    class MyDiyaddAdapter extends BaseAdapter {
        Context context;
        List<DiyaddBean> list;

        public MyDiyaddAdapter(Activity mActivity, List<DiyaddBean> list) {
            this.context = mActivity;
            this.list = list;
        }

        @Override
        public int getCount() {
            return list.size();
        }

        @Override
        public Object getItem(int position) {
            return list.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder viewHolder = null;
            if (convertView == null) {
                viewHolder = new ViewHolder();
                convertView = LayoutInflater.from(this.context).inflate(R.layout.diy_item_add, null);

                convertView.setTag(viewHolder);
            } else {
                viewHolder = (ViewHolder) convertView.getTag();
            }
            viewHolder.tvName.setText(list.get(position).Name);
            return convertView;
        }

        class ViewHolder {
            TextView tvName;
            public ImageView ivSelece;
        }
    }
}
